package com.thinkingcoder.tccache.core.command.string;

import static com.thinkingcoder.tccache.constant.CommandConstants.StringCmd.EXISTS;

import com.thinkingcoder.tccache.core.command.Command;
import com.thinkingcoder.tccache.core.model.Reply;
import com.thinkingcoder.tccache.core.TcCache;

/**
 * EXISTS command.
 */
public class ExistsCmd implements Command {
    @Override
    public String name() {
        return EXISTS;
    }

    @Override
    public Reply<?> exec(TcCache cache, String[] args) {
        String[] key = getParams(args);
        return Reply.integer(cache.exists(key));
    }
}
